package com.example.demo.model;

import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
@Data
public class Person {
    /**
     * 创造一个类存在多个对象的情况，观察属性注入是否报错*/
    private String name;
    private String address;

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", address='" + address + '\'' +
                '}';
    }

//    @Primary
    @Bean
    public Person studentOne() {
        Person person = new Person();
        person.name = "Lucy";
        person.address = "Beijing";
        return person;
    }

    @Bean
    public Person studentTwo() {
        Person person = new Person();
        person.name = "Jack";
        person.address = "Hangzhou";
        return person;
    }
}
